package hmvictor.jpql.nodes;

import hmvictor.jpql.Connection;
import hmvictor.jpql.ConnectionsTopComponent;
import java.util.List;
import org.openide.nodes.ChildFactory;
import org.openide.nodes.Node;

/**
 *
 * @author Victor
 */
public class ConnectionChildFactory extends ChildFactory<Connection> {
    private final List<Connection> connections;

    public ConnectionChildFactory(List<Connection> connections) {
        this.connections = connections;
    }

    @Override
    protected boolean createKeys(List<Connection> list) {
        connections.forEach((connection) -> {
            list.add(connection);
        });
        return true;
    }

    @Override
    protected Node createNodeForKey(Connection key) {
        return new ConnectionNode(key);
    }
    
    public void refreshChildren(){
        refresh(true);
    }

}
